<?
class Users_model extends Model
{
	private $tableName;
	
	public function __construct()
	{
		parent::Model();
		$this->obj =& get_instance();
		$this->tableName = 'users';
	}
	
	public function checkUser($loginDetails)
	{
		$result = null;
		$sql = " SELECT user_name
		FROM users
		WHERE user_name = '".$loginDetails['userName']."'
		AND user_passwd = '".$loginDetails['password']."'
		";
		$query = $this->db->query($sql);

		if ($query->num_rows() > 0) 	
		{
			$result = $query->row_array();
		}
		else
			$result = null;
		return $result;
	}
	

	/*
	*	add
	*	@PARA: $data
	*	@RETURN: id
	*/
	function addUser( $data ) 
	{
		// Load the database library
		$this->load->database();
		// Build up the SQL query string
		$sql = $this->db->insert_string($this->tableName, $data);
		$query = $this->db->query($sql);
		return $this->db->insert_id();
	}
}


?>